package org.crackjack.model;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "profiles")
public class Profile extends Identify implements Serializable {

    private static final long serialVersionUID = 5059845617492663715L;
    private String login;
    private String password;
    private ProfileType type;
    private Set<Appointment> appointments;

//    private List<Profile> masters;

    public Profile() {

    }

    @Column(name = "login")
    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    @Column(name = "password")
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Enumerated(EnumType.STRING)
    @Column(name = "type")
    public ProfileType getType() {
        return type;
    }

    public void setType(ProfileType type) {
        this.type = type;
    }

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "appointmentOwner", fetch = FetchType.LAZY)
    public Set<Appointment> getAppointments() {
        return appointments;
    }

    public void setAppointments(Set<Appointment> appointments) {
        this.appointments = appointments;
    }

//    @OneToMany(cascade = CascadeType.ALL)
//    @Column(name = "masters")
//    public List<Profile> getMasters() {
//        return masters;
//    }
//
//    public void setMasters(List<Profile> masters) {
//        this.masters = masters;
//    }

    @Override
    @Id
    @GeneratedValue
    @Column(name = "profile_id")
    public Long getId() {
        return super.getId();
    }
}
